# Author: Kang Lin <kl222@126.com>

project(RabbitCommonApp
    DESCRIPTION "Rabbit common example applicattion"
    )

include(GNUInstallDirs)

set(SOURCE_FILES
    main.cpp
    MainWindow.cpp
    MainWindow.h
    )

set(SOURCE_UI_FILES MainWindow.ui)

#翻译
#include(${CMAKE_SOURCE_DIR}/cmake/Qt5CorePatches.cmake)
#include(${CMAKE_SOURCE_DIR}/cmake/Translations.cmake)
#include(${CMAKE_SOURCE_DIR}/cmake/RabbitCommonUtils.cmake)

set(APP_ID "io.github.KangLin.RabbitCommon")
ADD_TARGET(NAME ${PROJECT_NAME}
    ISEXE
    SOURCE_FILES ${SOURCE_FILES} ${RESOURCE_FILES} ${SOURCE_UI_FILES}
    PRIVATE_DEFINITIONS ${App_PRIVATE_DEFINITIONS}
    PRIVATE_LIBS RabbitCommon ${QT_LIBRARIES}
    INCLUDE_DIRS "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/Src>"
        "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Src>"
    VERSION ${RabbitCommon_VERSION}
    )

if(NOT EXISTS ${CMAKE_BINARY_DIR}/etc/${PROJECT_NAME}.conf)
    configure_file(${CMAKE_SOURCE_DIR}/Src/etc/log4qt.conf
        ${CMAKE_BINARY_DIR}/etc/${PROJECT_NAME}.conf
        COPYONLY)
endif()
INSTALL_FILE(SOURCES ${CMAKE_BINARY_DIR}/etc/${PROJECT_NAME}.conf
    DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
    COMPONENT Application)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini)
    configure_file(${CMAKE_SOURCE_DIR}/Src/etc/logqt.ini
        ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini
        COPYONLY)
endif()
INSTALL_FILE(SOURCES ${CMAKE_BINARY_DIR}/etc/RabbitCommon_logqt.ini
    DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
    COMPONENT Application)

if(NOT ANDROID AND UNIX)
    INSTALL(FILES ${CMAKE_SOURCE_DIR}/share/${APP_ID}.desktop
        DESTINATION "share/applications" COMPONENT Application)
    INSTALL(FILES ${CMAKE_SOURCE_DIR}/Src/Resource/image/App.png
        RENAME ${APP_ID}.png
        DESTINATION "share/pixmaps" COMPONENT Application)
    
    INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/share/RabbitCommonApp.sh
        DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Application)
endif()
if(APPLE)
    file(COPY_FILE ${CMAKE_SOURCE_DIR}/Src/Resource/image/App.png
        ${APP_ID}.svg)
    target_add_resources(${PROJECT_NAME} . ${APP_ID}.svg)
endif()

set(OTHER_FILES
    ${CMAKE_SOURCE_DIR}/License.md
    ${CMAKE_SOURCE_DIR}/Authors.md
    ${CMAKE_SOURCE_DIR}/Authors_zh_CN.md
    ${CMAKE_SOURCE_DIR}/ChangeLog.md
    ${CMAKE_SOURCE_DIR}/ChangeLog_zh_CN.md
    )

# Install other files
INSTALL_FILE(SOURCES ${OTHER_FILES}
    DESTINATION ${CMAKE_INSTALL_DOCDIR}
        COMPONENT Application)



project(ExampleFileTransfer
    DESCRIPTION "Download example applicattion"
)
set(ExampleFileTransfer_SOURCE
    ${CMAKE_SOURCE_DIR}/Src/FileTransfer/ExampleFileTransfer.cpp)
ADD_TARGET(NAME ExampleFileTransfer
    ISEXE
    SOURCE_FILES ${ExampleFileTransfer_SOURCE}
    PRIVATE_LIBS RabbitCommon ${QT_LIBRARIES}
    INCLUDE_DIRS "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/Src>"
        "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Src>"
    VERSION ${RabbitCommon_VERSION}
    )
